/**
 * $Id$
 * Copyright 2009-2012 Oak Pacific Interactive. All rights reserved.
 */
package com.rabbit.base;

import java.util.LinkedList;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class BaseActivity extends FragmentActivity {

    public final String TAG = "BaseActivity";

    public static final String ACTION_SHOULD_RELOGIN = "action_should_relogin";

    public static final String ACTION_CLOSE_ALL = "action_close_all";

    private static LinkedList<String> activityNameList = new LinkedList<String>();

    private BroadcastReceiver mReloginReceiver;

    private BroadcastReceiver mCloseALlReceiver;

    /**
     * @author yuehui 创建的日期 ：2013-3-25 作用说明 ：清除数据，释放内存
     */
    protected void chearData() {

    }

    @Override
    protected void onDestroy() {
        if (mReloginReceiver != null) {
            unregisterReceiver(mReloginReceiver);
        }
        if (mCloseALlReceiver != null) {
            unregisterReceiver(mCloseALlReceiver);
        }
        super.onDestroy();
    }

    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);

        mCloseALlReceiver = new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                BaseActivity.this.finish();
            }
        };
        registerReceiver(mCloseALlReceiver, new IntentFilter(ACTION_CLOSE_ALL));
    }

    public static String getTopActivity() {
        return activityNameList.getLast();
    }
    

}
